<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //1.字符串的解构赋值(两种方法)
    //数组形式的解构赋值
    const [a, b, , , c] = 'hello'
    console.log(a, b, c);
    //对象形式的解构赋值
    const { 0: d, 1: e, length } = 'hello'
    console.log(a, b, length);
    //2.数值和布尔值的解构赋值
    //先将等号右边的值转为对象
    const { g = 1, toString } = 123;
    console.log(g, toString);
    /* const { h = 1, toString } = true;
    console.log(h, toString); */
    //3.由于undefined和null无法转为对象，所以无法解构赋值

  </script>
</body>

</html>